


# http://stackoverflow.com/questions/7787823/cmake-how-to-get-the-name-of-all-subdirectories-of-a-directory
macro(SUBDIRLIST subdirs curdir)
    file(GLOB children RELATIVE ${curdir} ${curdir}/*)
    set(dirs "")

    # message(STATUS "\"${curdir}\"'s sub-directories: {")
    foreach(child ${children})
        if(IS_DIRECTORY ${curdir}/${child})
        # message(STATUS "${child}")
            list(APPEND dirs ${child})
        endif()
    endforeach()
    # message(STATUS "}")

    set(${subdirs} ${dirs})
endmacro()

function(assign_source_group)
    foreach(_source IN ITEMS ${ARGN})
        if (IS_ABSOLUTE "${_source}")
            file(RELATIVE_PATH _source_rel
                "${CMAKE_CURRENT_SOURCE_DIR}"
                "${_source}"
            )
        else()
            set(_source_rel "${_source}")
        endif()

        get_filename_component(_source_path "${_source_rel}" PATH)
        string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")

        #message(STATUS ${_source_path_msvc})

        source_group("${_source_path_msvc}" FILES "${_source}")
    endforeach()
endfunction(assign_source_group)


